<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->

<table mat-table *ngIf="!isLoading" [dataSource]="data" fixedLayout="true">
  <caption>
    {{
      'applications.caption' | translate
    }}
  </caption>

  <!-- Position Column -->
  <ng-container matColumnDef="name">
    <th mat-header-cell *matHeaderCellDef scope="col"></th>
    <td
      mat-cell
      *matCellDef="let element"
      (click)="change(element)"
      matTooltip="{{ element.name.length >= maxElementLength ? element.name : '' }}"
      [matTooltipDisabled]="disableToolTip(element.name.length >= maxElementLength ? element.name : '')"
    >
      <div class="app--title mat-subheading-1">{{ element.name }}</div>
      <div class="app--name mat-body-2">
        <span class="app--name_label">{{ 'applications.owner' | translate }}: </span>
        <span class="app--name_owner">{{ element.owner }}</span>
      </div>
    </td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>

<ng-container *ngIf="data.length < 1 && !isLoading">
  <div class="create-new-message">
    <mat-icon svgIcon="info_new" inline="true"></mat-icon>
    <p class="mat-caption">{{ 'users.search.no_results' | translate }}</p>
  </div>
</ng-container>
